﻿@model IMall.Web.Models.ViewModels.Manager.CommodityInfo

@{
    ViewBag.Title = "EditCommodity";
    Layout = "~/Views/Shared/_ManagerLayout.cshtml";
}

<form action="~/Manager/EditCommodity" method="post">
    @Html.HiddenFor(m => m.Id)
    <div class="row">
        <div class="col-md-9">
            <div class="form-group">
                <label for="Type">选择商品分类</label>
                <select class="form-control" id="Type" name="Type" value="@Model.Type">
                    <option value="男装">男装</option>
                    <option value="女装">女装</option>
                    <option value="玩具">玩具</option>
                </select>
            </div>
            <div class="form-group">
                <label for="Name">商品名称</label>
                <input class="form-control" type="text" id="Name" name="Name" value="@Model.Name" />
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-3">
            <div class="form-group">
                <label for="Price">价格</label>
                <div class="input-group">
                    <span class="input-group-addon">￥</span>
                    <input class="form-control" type="text" id="Price" name="Price" value="@Model.Price"/>
                </div>
            </div>
        </div>
        <div class="col-lg-3">
            <div class="form-group">
                <label for="Freight">运费</label>
                <div class="input-group">
                    <span class="input-group-addon">￥</span>
                    <input class="form-control" type="text" id="Freight" name="Freight" value="@Model.Freight" />
                </div>
            </div>
        </div>
        <div class="col-lg-3">
            <div class="form-group">
                <label for="Number">数量</label>
                <div class="input-group">
                    <input class="form-control" type="text" id="Number" name="Number" value="@Model.Number"/>
                    <span class="input-group-addon">件</span>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-9">
            <div class="form-group" id="Icon">
                @if (Model != null && !string.IsNullOrWhiteSpace(Model.Icon))
                {
                    <div class="thumbnail">
                        <img src="/Content/List/@Model.Icon">
                    </div>
                }
            </div>
            <div class="form-group">
                <input type="file" id="File" name="File" class="layui-upload-file" lay-type="images">
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-success">提交</button>
            </div>
        </div>
    </div>
</form>

@section script{
    <script>
        $(function () {
            $("#EditCommodity").addClass("active");
            var layuiPage;

            layui.upload({
                url: '/Manager/UploadFile',
                method: 'POST',
                ext: 'jpg|png|jpeg',
                title: '上传商品图片',
                before: function (input) {
                    layuiPage = layer.open({
                        type: 3,
                    });
                },
                success: function (res, input) {
                    layer.close(layuiPage);
                    //alert(res.message);
                    $("#Icon").empty();
                    $("#Icon").append("<div class='thumbnail'><img src='/Content/List/" + res.attach + "'></div>");
                }
            });
        });
    </script>
}